home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 326-350 / disk_337 / cmanual / alerts.lzh / Alerts / Example1.c < prev   
C/C++ Source or Header  |  1990-01-30  |  4KB  |  108 lines

  1. /* Example1                                                          */
  2. /* This example displays an Alert message at the top of the display:   */
  3. /*                                                                     */
  4. /*  -----------------------------------------------------------------  */
  5. /*  |                                                               |  */
  6. /*  |  DANGER! Stupid user behind the keyboard!                     |  */
  7. /*  |                                                               |  */
  8. /*  |  Press Left Button to Retry   Press Right Button to Abort     |  */
  9. /*  |                                                               |  */
  10. /*  -----------------------------------------------------------------  */
  11.  
  12.  
  13.  
  14. #include <intuition/intuition.h>
  15.  
  16.  
  17.  
  18. struct IntuitionBase *IntuitionBase;
  19.  
  20.  
  21.  
  22. main()
  23. {
  24.   /* The string which will be printed out: */
  25.   char message[106];
  26.  
  27.   /* In this variable will we store what DisplayAlert() returned: */
  28.   BOOL result;
  29.  
  30.  
  31.  
  32.   /* Before we can use Intuition we need to open the Intuition Library: */
  33.   IntuitionBase = (struct IntuitionBase *)
  34.     OpenLibrary( "intuition.library", 0 );
  35.   
  36.   if( IntuitionBase == NULL )
  37.     exit(); /* Could NOT open the Intuition Library! */
  38.  
  39.  
  40.  
  41.   /* We will now fill the message array with our requirements: */
  42.   
  43.   /* Put the first string into the array. Remember to give space for 3 */
  44.   /* characters in the beginning. We will there store the x (2 bytes)  */
  45.   /* and y (1 byte) position of the text:                              */
  46.  
  47.   strcpy( message, "   DANGER! Stupid user behind the keyboard!");
  48.  
  49.  
  50.   /* Put the second string into the array. Remember to give space for  */
  51.   /* 5 (!) characters/bytes. We will there store the NULL sign which   */
  52.   /* finish of the first string, the TRUE sign which tells Intuition   */
  53.   /* that another string will come, and three bytes used to position   */
  54.   /* the text:                                                         */
  55.  
  56.   strcat( message,
  57.           "     Press Left Button to Retry   Press Right Button to Abort");
  58.     
  59.  
  60.   message[0]=0;       /* X position of the first string */
  61.   message[1]=32;      /*               - " -            */
  62.   message[2]=16;      /* Y             - " -            */
  63.  
  64.   message[43]='\0';   /* NULL sign which finish of the first string. */
  65.   message[44]=TRUE;   /* Continuation byte set to TRUE (new string). */
  66.   
  67.   message[45]=0;      /* X position of the second string. */
  68.   message[46]=32;     /*               - " -              */
  69.   message[47]=32;     /* Y             - " -              */
  70.  
  71.   message[104]='\0';  /* NULL sign which finish of the second string. */
  72.   message[105]=FALSE; /* Continuation byte set to FALSE (last string). */
  73.  
  74.  
  75.  
  76.   /* We will now display the Alert message: */
  77.   result = DisplayAlert( RECOVERY_ALERT, message, 48 );
  78.   
  79.   /*******************************************************************/
  80.   /* RECOVERY_ALERT: The system will survive after this message have */
  81.   /*                 been displayed.                                 */
  82.   /* message:        Pointer to the string which contains the text   */
  83.   /*                 we want to display + information about where we */
  84.   /*                 want to display it (x/y position) etc.          */
  85.   /* 48:             The height of the Alert box. (48 lines high)    */
  86.   /*******************************************************************/
  87.   
  88.   
  89.   
  90.   if(result)
  91.   {
  92.     /* result is equal to TRUE, left button was pressed: */
  93.     printf("RETRY: Left button was pressed\n");
  94.   }
  95.   else
  96.   {
  97.     /* result is equal to FALSE, right button was pressed: */
  98.     printf("ABORT: Right button was pressed\n");
  99.   }
  100.  
  101.  
  102.  
  103.   /* Close the Intuition Library since we have opened it: */
  104.   CloseLibrary( IntuitionBase );
  105.   
  106.   /* THE END */
  107. }
  108.